package java课题设计.功能类.修改学生或者删除学生;
import java课题设计.工具类.RandomID;

import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
 
//此类用于学生信息的修改(不能修改学号)
public class Revise extends JFrame implements MouseListener,DocumentListener {
    Font f=new Font("宋体",Font.BOLD,30);
    private JFrame pre;
    JTextField nametext=new JTextField();
    JTextField birthname=new JTextField();
    JButton boy=new JButton("男");
    JButton gril=new JButton("女");
    JButton sure = new JButton("确认修改");
    String stuname;
    String sex;
    String birthDate;
    String s;
 
    String PE,Java,Math;
    JLabel PEs=new JLabel("体育成绩");
    JLabel Javas=new JLabel("Java成绩");
    JLabel Maths=new JLabel("数学成绩");
    JTextField PETEXT=new JTextField();
    JTextField MathText=new JTextField();
    JTextField JavaText=new JTextField();
    String PEgrade,Javagrade,Mathgrade;
    public Revise() {
        extracted();
        iniImage();
 
        this.setVisible(true);
    }
    public void extracted(){
        this.setSize(700,700);//设置窗口大小
        this.setTitle("修改学生信息");//设置窗口标题
        this.setAlwaysOnTop(true);//设置此窗口总是位于其他窗口之上
        this.setDefaultCloseOperation(3);//设置关闭方式，3为关闭当前窗口则结束程序运行
        this.setLayout(null);//设置布局模式，null模式表示不受管理器设置管理，所有窗口的显示都由x,y显示
        this.setLocationRelativeTo(null);//设置窗口显示在中间位置
 
        sure.addMouseListener(this);
 
    }
    public void iniImage(){
 
        //添加学生姓名输入提示
        JLabel name=new JLabel("姓名");
        name.setBounds(180,100,300,45);
        name.setFont(f);
        this.getContentPane().add(name);
 
        //添加姓名输入框
 
        nametext.setBounds(280,105,250,35);
        this.getContentPane().add(nametext);
        //获取到用户输入的姓名
        nametext.addFocusListener(new FocusAdapter() {
            @Override
            public void focusLost(FocusEvent e) {
                stuname=nametext.getText();
            }
        });
 
 
        //添加性别输入提示
        JLabel sex=new JLabel("性别");
        sex.setBounds(180,175,300,45);
        sex.setFont(f);
        this.getContentPane().add(sex);
 
        //添加性别按钮选择
        boy.setBounds(280,175,70,45);
        boy.setFont(f);
        this.getContentPane().add(boy);
        gril.setBounds(380,175,70,45);
        gril.setFont(f);
        this.getContentPane().add(gril);
 
        //添加出生日期输入提示
        JLabel birth=new JLabel("出生日期");
        birth.setBounds(130,255,300,45);
        birth.setFont(f);
        this.getContentPane().add(birth);
 
        //添加出生日期输入框
        birthname.setBounds(280,260,250,35);
        this.getContentPane().add(birthname);
        //添加监听器获取用户输入的出生日期
        birthname.addFocusListener(new FocusAdapter() {
            @Override
            public void focusLost(FocusEvent e) {
                birthDate=birthname.getText();
            }
        });
 
        //添加体育成绩提示框
        PEs.setFont(f);
        PEs.setBounds(130,335,300,45);
        this.getContentPane().add(PEs);
 
 
        //添加体育成绩文本框
        PETEXT.setBounds(280,335,250,35);
        this.getContentPane().add(PETEXT);
        PETEXT.addFocusListener(new FocusAdapter() {
            @Override
            public void focusLost(FocusEvent e) {
                PEgrade=PETEXT.getText();
            }
        });
 
 
        //添加Java成绩提示框
        Javas.setFont(f);
        Javas.setBounds(130,405,300,45);
        this.getContentPane().add(Javas);
 
        //添加体育成绩文本框
        JavaText.setBounds(280,405,250,35);
        this.getContentPane().add(JavaText);
        JavaText.addFocusListener(new FocusAdapter() {
            @Override
            public void focusLost(FocusEvent e) {
                Javagrade=JavaText.getText();
            }
        });
 
        //添加数学成绩提示框
        Maths.setFont(f);
        Maths.setBounds(130,475,300,45);
        this.getContentPane().add(Maths);
 
        //添加体育成绩文本框
        MathText.setBounds(280,475,250,35);
        this.getContentPane().add(MathText);
        MathText.getDocument().addDocumentListener(new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent e) {
                Mathgrade = MathText.getText();
                //System.out.println("输入了出生日期");
            }
 
            @Override
            public void removeUpdate(DocumentEvent e) {
                Mathgrade = MathText.getText();
                //System.out.println("输入了出生日期");
            }
 
            @Override
            public void changedUpdate(DocumentEvent e) {
                Mathgrade = MathText.getText();
                //System.out.println("输入了出生日期");
            }
        });
 
 
        //添加确定添加学生按钮
        sure.setFont(f);
        sure.setBounds(250,545,180,45);
        this.getContentPane().add(sure);
 
    }
 
    @Override
    public void mouseClicked(MouseEvent e) {
        if(e.getSource()==sure){
            System.out.println("点击了修改按钮");
        }
    }
 
    @Override
    public void mousePressed(MouseEvent e) {
 
    }
 
    @Override
    public void mouseReleased(MouseEvent e) {
 
    }
 
    @Override
    public void mouseEntered(MouseEvent e) {
 
    }
 
    @Override
    public void mouseExited(MouseEvent e) {
 
    }
 
    @Override
    public void insertUpdate(DocumentEvent e) {
 
    }
 
    @Override
    public void removeUpdate(DocumentEvent e) {
 
    }
 
    @Override
    public void changedUpdate(DocumentEvent e) {
 
    }
}
